//package Filter;
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpFilter;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.IOException;
//
//@WebFilter("/*")
//public class LoginFilter extends HttpFilter {
//    public void destroy() {
//
//    }
//
//    public void doFilter(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException {
//
//        HttpSession session = req.getSession(true);
//        Object user = session.getAttribute("user");
//        String uri = req.getRequestURI();
//        if( uri.contains("/user.jsp") || uri.contains("/login/dgut")
//                || uri.contains("/LogoutServlet") || uri.contains("/login.html")
//                || uri.contains("/register.html") || uri.contains("/error.html")
//                || uri.contains("/register.jsp")  || uri.contains("/login.js")
//                || uri.contains("/ChangeHeadImgServlet")  || uri.contains("/LoginCheckServlet")
//                || uri.contains("/RegisterServlet") || uri.contains("/Servlet")){
//            chain.doFilter(req, resp);
//        }
//        else{
//            if(user == null)
//                resp.sendRedirect("/login.html");
//            else
//                chain.doFilter(req, resp);
//        }
//
//    }
//
//    public void init(FilterConfig config) throws ServletException {
//
//    }
//}